/**
 * 项目名：	Rumba Plan
 * 
 * 版权所有(C)，上海海鼎信息工程股份有限公司，2006，所有权利保留。
 * 
 * 文件名：	BUser.java
 * 模块说明：	
 * 修改历史：
 * 2006-8-20 - lxm - 创建。
 */
package com.hd123.rumba.user.biz;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.runtime.IPersistent;
import com.hd123.rumba.runtime.biz.BBaseEntity;
import com.hd123.rumba.user.IUser;

/**
 * @author lxm
 * 
 */
public class BUser extends BBaseEntity {

  /** 登录名 */
  private String login;

  /** 全名 */
  private String name;

  public static final String VALUE_PASSWORD_NOCHANGE = "_NOCHANGE_";

  /** 口令。未加密。 */
  private String password;

  /** 口令确认。未加密。 */
  private String passwordConfirm;

  /** 启用。 */
  private Boolean online;

  /** 有效期从 */
  private Date validFrom;

  /** 有效期到 */
  private Date validTo;

  /** 备注 */
  private String remark;

  /** 是否启用令牌登录 */
  private Boolean useToken;

  /** 令牌序列号 */
  private String tokenSn;

  /** 令牌PIN码 */
  private String tokenPin;

  /** 权限修改指令列表 */
  private List<BPermissionCommand> permCmds = new ArrayList();

  public void readFrom(IPersistent source) throws BusinessException {
    super.readFrom(source);
    if (source instanceof IUser) {
      login = ((IUser) source).getLogin();
      name = ((IUser) source).getName();
      password = VALUE_PASSWORD_NOCHANGE;
      passwordConfirm = VALUE_PASSWORD_NOCHANGE;
      online = ((IUser) source).getOnline();
      validFrom = ((IUser) source).getValidFrom();
      validTo = ((IUser) source).getValidTo();
      remark = ((IUser) source).getRemark();
      useToken = ((IUser) source).getUseToken();
      tokenSn = ((IUser) source).getTokenSn();
      tokenPin = ((IUser) source).getTokenPin();
    }
  }

  public String getNameCode() {
    return name + "[" + login + "]";
  }

  public String getLogin() {
    return login;
  }

  public void setLogin(String login) {
    this.login = login;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Boolean getOnline() {
    return online;
  }

  public void setOnline(Boolean online) {
    this.online = online;
  }

  public String getPassword() {
    return password;
  }

  public void setPassword(String password) {
    this.password = password;
  }

  public List<BPermissionCommand> getPermCmds() {
    return permCmds;
  }

  public void setPermCmds(List<BPermissionCommand> permCmds) {
    this.permCmds = permCmds;
  }

  public String getRemark() {
    return remark;
  }

  public void setRemark(String remark) {
    this.remark = remark;
  }

  public Date getValidFrom() {
    return validFrom;
  }

  public void setValidFrom(Date validFrom) {
    this.validFrom = validFrom;
  }

  public Date getValidTo() {
    return validTo;
  }

  public void setValidTo(Date validTo) {
    this.validTo = validTo;
  }

  public String getPasswordConfirm() {
    return passwordConfirm;
  }

  public void setPasswordConfirm(String passwordConfirm) {
    this.passwordConfirm = passwordConfirm;
  }

  public String getTokenPin() {
    return tokenPin;
  }

  public void setTokenPin(String tokenPin) {
    this.tokenPin = tokenPin;
  }

  public String getTokenSn() {
    return tokenSn;
  }

  public void setTokenSn(String tokenSn) {
    this.tokenSn = tokenSn;
  }

  public Boolean getUseToken() {
    return useToken;
  }

  public void setUseToken(Boolean useToken) {
    this.useToken = useToken;
  }
}
